package com.example.mongo.controller;

import com.example.mongo.utils.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/Redis")
public class RedisTestController {
    @Autowired
    RedisUtil redisUtil;

    @ResponseBody
    @RequestMapping(value = "/set",method = RequestMethod.GET)
    public String setRedis(@RequestParam String key,@RequestParam String value){
        redisUtil.set(key,value);
        System.out.println("key"+key+"value"+value);
        return "key"+key+"value"+value;
    }
    @ResponseBody
    @RequestMapping(value = "/get",method = RequestMethod.GET)
    public String getRedis(@RequestParam String key){
        System.out.println("key"+key+"value"+redisUtil.get(key));
        return "key"+key+"value"+redisUtil.get(key);
    }

}
